package rgbos.forum.persistance;

import java.sql.SQLException;

public class SqlTopicPost {

	public SqlTopicPost() {
		super();
	}

	public boolean checkExistTopic(int topicId) {
		java.sql.Statement stmt;
		try {
			stmt = SQLUtil.conn_.createStatement();
			java.sql.ResultSet rs = stmt.executeQuery
	        ("SELECT id FROM topics WHERE id = '"+topicId +"'");
			return (rs.first());
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			return false;
		}
	}

	public boolean checkExistPost(int postId) {
		java.sql.Statement stmt;
		try {
			stmt = SQLUtil.conn_.createStatement();
			java.sql.ResultSet rs = stmt.executeQuery
	        ("SELECT id FROM posts WHERE id = "+postId +"");
			return (rs.first());
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			return false;
		}
	}

}